import java.util.*;

public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        Shape[] shapes = new Shape[n];
        for (int i = 0; i < n; i++) {
            String s = scanner.nextLine();
            if (s.equals("rect")) {
                String s1 = scanner.nextLine();
                String[] strings = s1.split(" ");
                int width = Integer.parseInt(strings[0]);
                int length = Integer.parseInt(strings[1]);
                Shape shape = new Rectangle(width, length);
                shapes[i] = shape;
            } else if (s.equals("cir")) {
                int radius = Integer.parseInt(scanner.nextLine());
                Shape shape = new Circle(radius);
                shapes[i] = shape;
            }
        }
        System.out.println(sunAllPerimeter(shapes));
        System.out.println(sumAllArea(shapes));
        System.out.println(Arrays.toString(shapes));
        for (int i = 0; i < shapes.length; i++) {
            System.out.println(shapes[i].getClass() + "," + shapes[i].getClass().getSuperclass());
        }
    }

    public static double sumAllArea (Shape[] shapes) {
        double sumArea = 0;
        for (int i = 0; i < shapes.length; i++) {
            sumArea += shapes[i].getArea();
        }
        return sumArea;
    }

    public static double sunAllPerimeter (Shape[] shapes) {
        double sumPerimeter = 0;
        for (int i = 0; i < shapes.length; i++) {
            sumPerimeter += shapes[i].getPerimeter();
        }
        return sumPerimeter;
    }

}

abstract class Shape {
    static final double PI = 3.14;
    public abstract double getPerimeter();
    public abstract double getArea();

    @Override
    public String toString() {
        return "Shape[]";
    }
}

class Rectangle extends Shape {

    int width;
    int length;

    public Rectangle(int width, int length) {
        this.width = width;
        this.length = length;
    }

    @Override
    public double getPerimeter() {
        return 2 * (width + length);
    }

    @Override
    public double getArea() {
        return width * length;
    }

    @Override
    public String toString() {
        return "Rectangle [" +
                "width=" + width +
                ", length=" + length +
                ']';
    }
}

class Circle extends Shape {

    int radius;

    public Circle(int radius) {
        this.radius = radius;
    }

    @Override
    public double getPerimeter() {
        return 2 * super.PI * radius;
    }

    @Override
    public double getArea() {
        return super.PI * radius *radius;
    }

    @Override
    public String toString() {
        return "Circle [" +
                "radius=" + radius +
                ']';
    }
}

